<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
    
    <body>
        <ui:composition template="template/templateIntern.xhtml"> 
            <ui:define name="pageTitle">                
                <h:outputText value="timeitj - Project: #{ProjectController.project.name}" />    
            </ui:define>              
            <ui:define name="bodyContent">                
                
                <h3><h:outputText value="Project: #{ProjectController.project.name}" /></h3>
                <p><h:outputText value="Owner: #{ProjectController.project.owner.name}" /></p>
                <p><h:outputText value="Description: #{ProjectController.project.description}" /></p>
                <h:dataTable id="workersTable" binding="#{ParticipanceController.dataTable}" value="#{ParticipanceController.personsByProject}" var="participance">
                    <h:column>
                        <h:outputText value="#{participance.person.login}" />
                    </h:column>    
                    <h:column>
                        <h:outputText value="#{participance.person.name}" />
                    </h:column>
                    <h:column>
                        <h:form>
                            <a4j:commandButton value="fire worker" reRender="workersTable" actionListener="#{ParticipanceController.deleteParticipance}">
                                <a4j:actionparam name="index" assignTo="#{ParticipanceController.affectedRowIndex}"  
                                                 value="#{ParticipanceController.dataTable.rowIndex}"/>
                            </a4j:commandButton>
                        </h:form>
                    </h:column>
                </h:dataTable>
                <h:form>
                    <p> 
                        <h:selectOneMenu id="hireOptions" value="#{ParticipanceController.participance.person}">
                            <f:selectItems value="#{UserController.allUsers}" />
                        </h:selectOneMenu>
                        <a4j:commandButton value="hire worker" reRender="workersTable" actionListener="#{ParticipanceController.createParticipance}" />
                    </p>
                </h:form>
                
            </ui:define>
        </ui:composition>
    </body>
</html>
